<?php
/* Datenbank Navigation abfragen */
if(isset($_SESSION['log_name']))
{
	$navigation = mysql_query('
			SELECT *
			FROM navigation
			WHERE nav_unav = 0
			ORDER BY nav_pos;');

	$u_navigation = mysql_query('
			SELECT *
			FROM navigation
			WHERE nav_unav > 0
			ORDER BY nav_pos;');
}
else
{
	$navigation = mysql_query('
			SELECT *
			FROM navigation
			WHERE nav_sbar > 0 AND nav_unav = 0
			ORDER BY nav_pos;');

	$u_navigation = mysql_query('
			SELECT *
			FROM navigation
			WHERE nav_sbar > 0 AND nav_unav > 0
			ORDER BY nav_pos;');
}

/* Ausgabe der Navigation */
echo '<ul>';
for($row = 0; $row < mysql_num_rows($navigation); $row++)
{
	$id = mysql_result($navigation, $row, 'nav_id');
	$bez = mysql_result($navigation, $row, 'nav_bez');
	$link = mysql_result($navigation, $row, 'nav_link');
	$sbar = mysql_result($navigation, $row, 'nav_sbar');

	echo '<li>';
	/* Wenn eingelogt */
	if(isset($_SESSION['log_name']))
	{
		echo '<a href="index.php?id=nav_edit&amp;edit='.$id.'"><img src="images/edit.png" style="width: 10px; height: 10px;" alt="Edit" />&nbsp;';

		if($sbar == 1)
		{
			echo '<img src="images/sbar.gif" style="width: 10px; height: 10px;"/>&nbsp;';
		}
		else
		{
			echo '<img src="images/usbar.gif" style="width: 10px; height: 10px;"/>&nbsp;';
		}
		echo '</a>';
	}
	echo '<a href="index.php?id='.$link.'">'.$bez.'</a>';
	echo '</li>';


	/* Schlaufe fuer Sekundaernavigation */
	for($u_row = 0; $u_row < mysql_num_rows($u_navigation); $u_row++)
	{
		if(mysql_result($navigation, $row, 'nav_id') == mysql_result($u_navigation, $u_row, 'nav_unav'))
		{
			$u_id = mysql_result($u_navigation, $u_row, 'nav_id');
			$u_bez = mysql_result($u_navigation, $u_row, 'nav_bez');
			$u_link = mysql_result($u_navigation, $u_row, 'nav_link');
			$u_sbar = mysql_result($u_navigation, $u_row, 'nav_sbar');

			/* Wenn eingelogt */
			/* Ausgabe Sekundaernavigation */
			if(isset($_SESSION['log_name']))
			{
				echo '<a href="index.php?id=nav_edit&amp;edit='.$u_id.'"><img src="images/edit.png" width="10" height="10" border="0" alt="Edit" />&nbsp;';
				if($u_sbar == 1)
				{
					echo '<img src="images/sbar.gif" width="10" height="10" border="0" />';
				}
				else
				{
					echo '<img src="images/usbar.gif" width="10" height="10" border="0" />';
				}
				echo '</a>';
			}
			echo '<ul>';
			echo '<li><a href="index.php?id='.$u_link.'">TEST_Untermenue: '.$u_bez.'</a>';
			echo '</ul>';
		}
	}
}
echo '</ul>';
?>